package com.anan;

import javafx.scene.media.AudioClip;

import java.io.File;
import java.net.URI;

/**
 * @Author: Painter
 * @project_name: aircraft-war
 * @system_login: sunshine
 * @time: 2023/11/520:18
 */



public class PlayerMusic {
    public PlayerMusic() {

    }

    public static void backgroundmusic() {
        new Thread(() -> {
            File file = new File("src/main/java/sound/bjmusic.wav");
            URI uri = file.toURI();
//            System.out.println(uri);
            AudioClip audioClip = new AudioClip(uri.toString());
            audioClip.setCycleCount(99);// 播放次数
            audioClip.play();
        }).start();
    }

    public static void bulletmusic() {
        new Thread(() -> {
            File file = new File("src/main/java/sound/bullet.wav");
            URI uri = file.toURI();
//            System.out.println(uri);
            AudioClip audioClip = new AudioClip(uri.toString());
            audioClip.setCycleCount(1);// 播放次数
            audioClip.play();
        }).start();
    }

    public static void smallBombMusic() {
        new Thread(() -> {
            File file = new File("src/main/java/sound/enemy1_down.wav");
            URI uri = file.toURI();
//            System.out.println(uri);
            AudioClip audioClip = new AudioClip(uri.toString());
            audioClip.setCycleCount(1);// 播放次数
            audioClip.play();
        }).start();
    }

    public static void midBombMusic() {
        new Thread(() -> {
            File file = new File("src/main/java/sound/enemy2_down.wav");
            URI uri = file.toURI();
//            System.out.println(uri);
            AudioClip audioClip = new AudioClip(uri.toString());
            audioClip.setCycleCount(1);// 播放次数
            audioClip.play();
        }).start();
    }

    public static void bigBombMusic() {
        new Thread(() -> {
            File file = new File("src/main/java/sound/enemy3_down.wav");
            URI uri = file.toURI();
//            System.out.println(uri);
            AudioClip audioClip = new AudioClip(uri.toString());
            audioClip.setCycleCount(1);// 播放次数
            audioClip.play();
        }).start();
    }

    public static void BombMusic() {
        new Thread(() -> {
            File file = new File("src/main/java/sound/bomb.wav");
            URI uri = file.toURI();
//            System.out.println(uri);
            AudioClip audioClip = new AudioClip(uri.toString());
            audioClip.setCycleCount(1);// 播放次数
            audioClip.play();
        }).start();
    }

    public static void supplyBombMusic() {
        new Thread(() -> {
            File file = new File("src/main/java/sound/get_bomb.wav");
            URI uri = file.toURI();
//            System.out.println(uri);
            AudioClip audioClip = new AudioClip(uri.toString());
            audioClip.setCycleCount(1);// 播放次数
            audioClip.play();
        }).start();
    }

    public static void main(String[] args) throws Exception {
//        PlayerMusic.backgroundmusic();
//        PlayerMusic.bulletmusic();
//        Thread.sleep(10000000);
    }
}